﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using HerGoS.Interfaces.Observer;
using System.Configuration;
using HerGoS.DAO;
using HerGoS.WebUI.GlobalUI;

namespace HerGoS.WebUI
{
    public class MyApplication
    {
        //Se jecuta al Iniciar la aplicacion
        public static void Init()
        {
            LoadConnectionString();
            SubscribeObservers();
            SiteController.LoadPagesModules();

        }

        static void LoadConnectionString()
        {
            //Carga la lista estatica con las conecciones configuradas en el web.config
            foreach (ConnectionStringSettings conn in ConfigurationManager.ConnectionStrings)
            {
                RepositoryFactory.AddConnection(conn.Name, conn.ConnectionString);
            }
        }

        static void SubscribeObservers()
        {
            //Subcribe a los observers (Test)
            ObserverApplicationStart.Instance.Subscribe(new HerGoS.Administration.Engine.CheckApplicationStart());
            ObserverSessionEnd.Instance.Subscribe(new HerGoS.Administration.Engine.CheckSessionEnd());
        }
    }
}